group { name: "elm/diskselector/base/default";
   parts {
      part { name: "bg"; type: RECT;
         mouse_events: 0;
         description { state: "default" 0.0;
            color_class: "/bg/normal/diskselector";
         }
      }
      part { name: "clipper"; type: RECT;
         description { state: "default" 0.0;
            rel.to: "bg";
         }
      }
      part { name: "elm.swallow.content"; type: SWALLOW;
         clip_to: "clipper";
         scale;
         description { state: "default" 0.0;
            rel.to: "bg";
//            rel1.offset: 4 4;
//            rel2.offset: -5 -5;
//            min: 28 28;
            min: 80 20;
            offscale;
         }
      }
   }
}

group { name: "elm/diskselector/item/default";
   data {
      item: "len_threshold" "14";
      item: "display_item_num" "3";
      item: "min_height" "-1";
      item: "min_width" "-1";
   }
   parts {
      part { name: "elm.swallow.icon"; type: SWALLOW;
         scale: 1;
         description { state: "default" 0.0;
            fixed: 1 1;
            align: 0.0 0.5;
            rel1 {
               relative: 0 0;
               offset: 0 0;
            }
            rel2 {
               relative: 0 1;
               offset: 0 -1;
            }
            min: 20 20;
            rel1.offset: 4 4;
            rel2.offset: 4 -5;
            offscale;
         }
         description { state: "show" 0.0;
            inherit: "default" 0.0;
            min: 20 20;
            aspect: 1.0 1.0;
         }
         description { state: "default_small" 0.0;
            inherit: "default" 0.0;
            min: 10 10;
            aspect: 1.0 1.0;
         }
         description { state: "left_side" 0.0;
            inherit: "default" 0.0;
            rel1.relative: 0 0.2;
            rel2.relative: 0 0.8;
            color: 255 255 255 160; // no cc
            min: 10 10;
            aspect: 1.0 1.0;
         }
         description { state: "right_side" 0.0;
            inherit: "left_side" 0.0;
            rel1.relative: 0.4 0.2;
            rel2.relative: 0.4 0.8;
            color: 255 255 255 160; // no cc
            min: 10 10;
            aspect: 1.0 1.0;
         }
         description { state: "icon_only" 0.0;
            inherit: "default" 0.0;
            align: 0.5 0.5;
            rel1.relative: 0 0;
            rel2.relative: 1 1;
            min: 20 20;
            aspect: 1.0 1.0;
         }
      }
      part { name: "elm.text"; type: TEXT;
         scale: 1;
         description { state: "default" 0.0;
            color_class: "/fg/normal/diskselector";
            rel1.relative: 1 0.0;
            rel1.to_x: "elm.swallow.icon";
            rel1.offset: 4 4;
            rel2.offset: -5 -5;
            rel2.relative: 1.0 1.0;
            visible: 0;
            text { font: FN; size: 10;
               align: 0.5 0.5;
               min: 0 1;
            }
            offscale;
         }
         description { state: "show" 0.0;
            inherit: "default" 0.0;
            visible: 1;
         }
         description { state: "default_small" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            text.size: 10;
         }
         description { state: "left_side" 0.0;
            inherit: "default" 0.0;
            color: 128 128 128 255; // no cc
            text.size: 8;
            visible: 1;
            text.align: 0.2 0.5;
         }
         description { state: "right_side" 0.0;
            inherit: "default" 0.0;
            color: 128 128 128 255; // no cc
            visible: 1;
            text.size: 8;
            text.align: 0.8 0.5;
         }
         description { state: "text_only" 0.0;
            inherit: "default" 0.0;
            visible: 1;
            rel1.relative: 0 0;
            rel2.relative: 1 1;
         }
         description { state: "text_only_left_side" 0.0;
            inherit: "left_side" 0.0;
            rel1.relative: 0 0;
            rel2.relative: 1 1;
         }
         description { state: "text_only_right_side" 0.0;
            inherit: "right_side" 0.0;
            visible: 1;
            rel1.relative: 0 0;
            rel2.relative: 1 1;
         }
      }
      part { name: "over1"; type: RECT;
         mouse_events: 1;
         repeat_events: 1;
         ignore_flags: ON_HOLD;
         description { state: "default" 0.0;
            color: 0 0 0 0; // no cc
         }
      }
   }

   programs {
      script {
         public item_style; // 0:icon and text, 1:text only, 2:con only
      }
      program { name: "center_text";
         signal: "elm,state,center"; source: "elm";
         script {
            if (get_int(item_style) == 1)
              set_state(PART:"elm.text", "text_only", 0.0);
            else if (get_int(item_style) == 2)
              set_state(PART:"elm.swallow.icon", "icon_only", 0.0);
            else
              {
                 set_state(PART:"elm.text", "show", 0.0);
                 set_state(PART:"elm.swallow.icon", "show", 0.0);
              }
         }
      }
      program { name: "center_small_text";
         signal: "elm,state,center_small"; source: "elm";
         action: STATE_SET "default_small" 0.0;
         target: "elm.text";
         target: "elm.swallow.icon";
      }
      program { name: "l_side_text";
         signal: "elm,state,left_side"; source: "elm";
         script {
            if (get_int(item_style) == 1)
              set_state(PART:"elm.text", "text_only_left_side", 0.0);
            else if (get_int(item_style) == 2)
              set_state(PART:"elm.swallow.icon", "left_side", 0.0);
            else
              {
                 set_state(PART:"elm.text", "left_side", 0.0);
                 set_state(PART:"elm.swallow.icon", "left_side", 0.0);
              }
         }
      }
      program { name: "r_side_text";
         signal: "elm,state,right_side"; source: "elm";
         script {
            if (get_int(item_style) == 1)
              set_state(PART:"elm.text", "text_only_right_side", 0.0);
            else if (get_int(item_style) == 2)
              set_state(PART:"elm.swallow.icon", "right_side", 0.0);
            else
              {
                 set_state(PART:"elm.text", "right_side", 0.0);
                 set_state(PART:"elm.swallow.icon", "right_side", 0.0);
              }
         }
      }
      program { name: "icon_only";
         signal: "elm,state,icon,only"; source: "elm";
         script {
            set_state(PART:"elm.swallow.icon", "icon_only", 0.0);
            set_int(item_style, 2);
         }
      }
      program { name: "text_only";
         signal: "elm,state,text,only"; source: "elm";
         script {
            set_state(PART:"elm.text", "text_only", 0.0);
            set_int(item_style, 1);
         }
      }
      program { name: "text_icon";
         signal: "elm,state,text,icon"; source: "elm";
         script {
            set_int(item_style, 0);
         }
      }
      program { name: "field_click";
         signal: "mouse,clicked,1"; source: "over1";
         action: SIGNAL_EMIT "elm,action,click" "elm";
      }
   }
}

///////////////////////////////////////////////////////////////////////////////
// diskselector item : datetime style
///////////////////////////////////////////////////////////////////////////////
group { name: "elm/diskselector/item/datetime/default";
   data {
      item: "len_threshold" "10";
      item: "min_height" "-1";
      item: "min_width" "-1";
   }
   parts {
     part { name: "elm.text"; type: TEXT;
        mouse_events: 0;
        scale: 1;
        description { state: "default" 0.0;
           color_class: "/fg/normal/diskselector";
           min: 10 10;
           align: 0.0 0.0;
           visible: 1;
           rel1.offset: 4 4;
           rel2.offset: -5 -5;
           offscale;
           text { font: FN; size: 10;
              min: 1 1;
              ellipsis: -1;
           }
        }
        description { state: "center_sel" 0.0;
           inherit: "default" 0.0;
           color_class: "/fg/selected/diskselector";
        }
        description { state: "left_side" 0.0;
           inherit: "default" 0.0;
           color: 128 128 128 255; // no cc
           text.align: 0.2 0.5;
        }
        description { state: "left_side_sel" 0.0;
           inherit: "default" 0.0;
           color_class: "/fg/selected/diskselector";
           text.align: 0.2 0.5;
        }
        description { state: "right_side" 0.0;
           inherit: "default" 0.0;
           color: 128 128 128 255; // no cc
           text.align: 0.8 0.5;
        }
        description { state: "right_side_sel" 0.0;
           inherit: "default" 0.0;
           color_class: "/fg/selected/diskselector";
           text.align: 0.8 0.5;
        }
     }
     part { name: "over1"; type: RECT;
        mouse_events: 1;
        repeat_events: 1;
        ignore_flags: ON_HOLD;
        description {
           state: "default" 0.0;
           color: 0 0 0 0; // no cc
        }
     }
   }
   programs {
      script {
         public field_pos; // center = 0,left = 1, right =2.
         public field_selected; //field is selected(1) or not(0).

         public update_state() {
            new pos, is_sel;
            pos = get_int(field_pos)
            is_sel = get_int(field_selected);
            if (is_sel == 1) {
               if (pos == 0)
                 set_state(PART:"elm.text", "center_sel", 0.0);
               else if (pos == 1)
                 set_state(PART:"elm.text", "left_side_sel", 0.0);
               else if (pos == 2)
                 set_state(PART:"elm.text", "right_side_sel", 0.0);
            } else if (is_sel == 0) {
               if (pos == 0)
                 set_state(PART:"elm.text", "default", 0.0);
               else if (pos == 1)
                 set_state(PART:"elm.text", "left_side", 0.0);
               else if (pos == 2)
                 set_state(PART:"elm.text", "right_side", 0.0);
            }
         }
      }
      program { signal: "elm,state,selected"; source: "elm";
         script {
            set_int(field_selected, 1);
            update_state();
         }
      }
      program { signal: "elm,state,default"; source: "elm";
         script {
            set_int(field_selected, 0);
            update_state();
         }
      }
      program { signal: "elm,state,center"; source: "elm";
         script {
            set_int(field_pos, 0);
            update_state();
         }
      }
      program { signal: "elm,state,center_small"; source: "elm";
         script {
            set_int(field_pos, 0);
            update_state();
         }
      }
      program { signal: "elm,state,left_side"; source: "elm";
         script {
            set_int(field_pos, 1);
            update_state();
         }
      }
      program { signal: "elm,state,right_side"; source: "elm";
         script {
            set_int(field_pos, 2);
            update_state();
         }
      }
      program { signal: "mouse,clicked,1"; source: "over1";
         action: SIGNAL_EMIT "elm,action,click" "elm";
      }
   }
}
